<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>左侧菜单树2</title>
<%@ include file="/WEB-INF/jsp/common/inc.jsp" %>
<!--  树结构  -->
<script type="text/javascript" src="${_resources}js/jquery.ztree.core.js"></script>
<link rel="stylesheet" href="${_resources}css/zTreeStyle.css" type="text/css">


<link href='${_resources}css/style.css' type='text/css' rel='stylesheet' />

<script type="text/javascript">
	
 	var	parentId;
	var ztree;
	var setting = {	
			view: {
				fontCss : {border:"0",background:"none","text-decoration":"none"},
                showIcon: false,
    			showLine: true,
    			selectedMulti: false,
    			dblClickExpand: false	
    		},
		data: {
			simpleData: {
				enable: true,
				idKey: "menuId",
				pIdKey: "parentId"
			}
		},
		callback: {
			onNodeCreated: this.onNodeCreated,				
			onClick:onClick			
		}
	};
	
	var zNodes = eval('(${menuList})');
	$(document).ready(function(){
		//loadTree();
		ztree = $.fn.zTree.init($("#treeDemo"), setting, zNodes);
		if("zuzhizichan" == "${needExpandNodeId}"){
			var div = document.getElementById("templatelist");
			div.src ="${_baseUrl}/organizeassetsKTController/showOrganizeassetsIndex?parentMenuId=${menuInfo.menuId}"+"&random="+Math.random();
		}else{
			ztree.expandNode(ztree.getNodeByParam("menuId","${needExpandNodeId}",null));//展开指定节点
			ztree.setting.callback.onClick(null, ztree.setting.treeId, ztree.getNodeByParam("menuId","${needExpandNodeId}",null));//触发函数
		}
		
		$("#menuName").click(function(){
			if(this.innerText.indexOf("组织资产") != -1){
				ztree.expandNode(ztree.getNodeByParam("menuId","${needExpandNodeId}",null));//展开指定节点
				var div = document.getElementById("templatelist");
				div.src ="${_baseUrl}/organizeassetsKTController/showOrganizeassetsIndex?parentMenuId=${menuInfo.menuId}"+"&random="+Math.random();				
			}			
		});
		
	});
	function loadTree(nodeId){
		ztree = $.fn.zTree.init($("#treeDemo"), setting, zNodes);
		ztree.selectNode(ztree.getNodeByParam("nodeId",nodeId,null));//选中指定节点
		ztree.setting.callback.onClick(null, ztree.setting.treeId, ztree.getNodeByParam("nodeId",nodeId,null));//触发函数
		//zTree.checkNode(nodes[0].children[0], true, true);
	}
	
	function onClick(e,treeId, treeNode) {
		parentId=treeNode.menuId;
		var zTree = $.fn.zTree.getZTreeObj("treeDemo");
        zTree.expandNode(treeNode);
        var div = document.getElementById("templatelist");
        div.src ="${_baseUrl}"+treeNode.menuUrl+"?menuId="+treeNode.menuId+"&random="+Math.random();//+"&menuName="+treeNode.name;
	}
	
	
	function skip(url,menuId){
		var div = document.getElementById("templatelist");
		if(url.indexOf("showTestProcessDemandMenu") != -1){
			var projectId = url.substring(url.indexOf("=")+1,url.indexOf("&"));
			parent.skipModule1("测试管理","${_baseUrl}/jurisdiction/menuList",'',"d42f113426d7436ba1683856cc1697a1",projectId);
		}else{
			if(url.indexOf("?") > 0){
				div.src ="${_baseUrl}"+url+"&menuId="+menuId+"&random="+Math.random();
			}else{
				div.src ="${_baseUrl}"+url+"?menuId="+menuId+"&random="+Math.random();
			}
		}
	}
	
	
	function refreshTree(){
		 var menuId="${menuInfo.menuId}"; 
		 $.ajax({
				url : "${_baseUrl}/jurisdiction/menuTreeList?menuId="+menuId,
				type : "post",
				dataType : "json",
				async : false,//** ！重要 同步请求。效果:ajax未进行则其他代码不运行
				success : function(json) {
					if(json.code=="1"){
						zNodes= eval(json.data);
						ztree = $.fn.zTree.init($("#treeDemo"), setting, zNodes);
						ztree.selectNode(ztree.getNodeByParam("menuId",parentId,null));//选中指定节点
						ztree.expandNode(ztree.getNodeByParam("menuId",parentId,null));//展开指定节点	
						$("#menuName").click(function(){
							if(this.innerText.indexOf("组织资产") != -1){
								ztree = $.fn.zTree.init($("#treeDemo"), setting, zNodes);
								ztree.expandNode(ztree.getNodeByParam("menuId","${needExpandNodeId}",null));//展开指定节点
								var div = document.getElementById("templatelist");
								div.src ="${_baseUrl}/organizeassets/showOrganizeassetsIndex?random="+Math.random();				
							}			
						});
					}	
				},
				error:function(data){
					layer.msg("系统错误,请联系管理员");
				}
			});
	}
	$(function(){
		$(".aaaaa").css("margin-left","15px");
		$(".aaaaa")[0].click();	
	})
	
	function defineTemplateSort(){	
		layer.open({
		  type: 2, 
		  title:'类别管理',
		  area: ['500px', '370px'],
		  shade: 0.3, //遮罩透明度
		  fixed: false, //不固定
		  maxmin: true,
		  shim: true,
		  content: '${_baseUrl}/OMenuDescribe/showOrganizeassetsMenuTree?menuId=${parentMenuId}'+'&random='+Math.random(),
		  cancel: function(index, layero){ 
			    layer.close(index)
			    window.location.reload(true);
			}    
		});
	}
</script>
<style type="text/css">
.btn { width:20px;display:inline-block; position:absolute; left:251px; z-index:999; }
.btn div { position:absolute; top:39%;width:20px;left:1px; vertical-align:center;}
.main_left .left_menu_tree .ztree li a .node_name{ display: inline-block;max-width:75px;overflow: hidden;/*内容超出后隐藏*/text-overflow: ellipsis;/* 超出内容显示为省略号*/white-space: nowrap;/*文本不进行换行*/}
.main_left .left_menu_tree .ztree li.level0 a .node_name{max-width: 150px;}
.main_left .left_menu_tree .ztree li.level1 a .node_name{max-width: 105px;}
.main_left .left_menu_tree .ztree li.level2 a .node_name{max-width: 70px;}
.main_left .left_menu_tree .ztree li.level3 a .node_name{max-width: 30px;}
.main_left .left_menu_tree .ztree li.level4 a .node_name{max-width: 10px;}
#box{width:100%;height:100%;overflow:hidden;}
		#main-left{width:-moz-calc(15% - 5px);width:-webkit-calc(15% - 5px);width:calc(15% - 5px);height:100%;float:left;}
		#btn1{width:5px;height:100%;cursor: w-resize;float:left;background: #ccc;}
		#main-right{float:right;width:85%;height:100%;}
		.ztree li a{line-height: 10px;}
</style>
</head>
<body>
<div id="box" class="main">
    <div id="main-left" class="zTreeDemoBackground" style="overflow-x: hidden;">
        <div class="left_menu_tree" style="margin-left: 10px;">
        <div style="margin-top:10px">
        	<%-- <a class="aaaaa" href="${_baseUrl}/organizeassetsKTController/showOrganizeassetsIndex?parentMenuId=${menuInfo.menuId}" target='aaaaaaa' style="font-size: 14px;color:#666;margin-left:10px"><span>全部资产</span></a> --%>
        </div>
            <ul id="treeDemo" class="ztree" style="overflow-x: hidden;"></ul>
        </div>
    </div>
    <!-- 图标按钮开始  -->
    <div id="btn1"></div>
    <!-- 图标按钮结束 -->
    <div id="main-right">
        <iframe id="templatelist" width='100%' height='100%' src="" frameborder="0" scrolling="auto" name="aaaaaaa">
        </iframe>
    </div>
</div>
</body>
<script type="text/javascript">
	var  resizeTimer = null;
	window.onload = function(){
		huadong();
		initHeight();			
	}
	window.onresize = function(){
	    if(resizeTimer) clearTimeout(resizeTimer);
	    resizeTimer = setTimeout("initHeight();huadong();",100);
	 }
	function initHeight(){
		var topH = 0; 
		if(navigator.userAgent.indexOf("MSIE")>0 || navigator.userAgent.indexOf("like Gecko")>0) {//IE浏览器
			initheight = document.documentElement.clientHeight-topH;
		}
		if(navigator.userAgent.indexOf("Firefox")>0){//Firefox浏览器
			initheight = document.documentElement.clientHeight-topH;
		}
		if(navigator.userAgent.indexOf("Opera")>0){//Opera浏览器
			initheight = document.body.clientHeight-topH;
		}
		if(navigator.userAgent.indexOf("Chrome")>0){//Chrome谷歌浏览器
			initheight = document.documentElement.clientHeight-topH;
		}
		if(navigator.userAgent.indexOf("Safari")>0){//Safari浏览器
			initheight = document.documentElement.clientHeight-topH;
		}
		$("#treeDemo").css("height",initheight );
		$("#btn1").css("height",initheight );
		$("#main-right").css("height",initheight);
	}
	function ssssssss(htmlw){
 		var childWindow = $("#templatelist")[0].contentWindow;
 		var box = document.getElementById("box");
 		var boxw =box.clientWidth;
 		var left = document.getElementById("main-left");
		var right = document.getElementById("main-right");
		left.style.width = oleft + "px";
		right.style.width = (htmlw - oleft - 50) + "px";
 	}
 	
 	function hhhhhhhhh(htmlw){
 		var childWindow = $("#templatelist")[0].contentWindow;
 		var box = document.getElementById("box");
 		var boxw =box.clientWidth;
 		var left = document.getElementById("main-left");
		var right = document.getElementById("main-right");
		left.style.width = oleft + "px";
		right.style.width = (htmlw - oleft - 50-170) + "px";
 	}
	
 	function bbbbb(htmlw){
 		var childWindow = $("#templatelist")[0].contentWindow;
 		var box = document.getElementById("box");
 		var boxw =box.clientWidth;
 		var left = document.getElementById("main-left");
		var right = document.getElementById("main-right");
		var leftw = left.clientWidth||left.offsetWidth;
		right.style.width = (htmlw - oleft - 50) + "px";
		left.style.width = oleft + "px";
 	}
 	
 	function bbbbb1(htmlw){
 		var childWindow = $("#templatelist")[0].contentWindow;
 		var box = document.getElementById("box");
 		var boxw =box.clientWidth;
 		var left = document.getElementById("main-left");
		var right = document.getElementById("main-right");
		var leftw = left.clientWidth||left.offsetWidth;
		right.style.width = (htmlw - oleft - 50+170) + "px";
		left.style.width = oleft + "px";
 	}
 	
 	function xxxxx(htmlw){
 		var childWindow = $("#templatelist")[0].contentWindow;
 		var box = document.getElementById("box");
 		var boxw =box.clientWidth;
 		var left = document.getElementById("main-left");
		var right = document.getElementById("main-right");
		var leftw = left.clientWidth||left.offsetWidth;
		right.style.width = (htmlw - oleft - 50-340) + "px";
		left.style.width = oleft + "px";
 	}
 	
 	function xxxxx1(htmlw){
 		var childWindow = $("#templatelist")[0].contentWindow;
 		var box = document.getElementById("box");
 		var boxw =box.clientWidth;
 		var left = document.getElementById("main-left");
		var right = document.getElementById("main-right");
		var leftw = left.clientWidth||left.offsetWidth;
		right.style.width = (htmlw - oleft - 50-170) + "px";
		left.style.width = oleft + "px";
 	}
 	
 	var oleft = 0;
 	$(function(){
 		var resize = document.getElementById("btn1");
 		var childWindow = $("#templatelist")[0].contentWindow;
 		var box = document.getElementById("box");
 		var left = document.getElementById("main-left");
 		oleft =left.clientWidth||left.offsetWidth;
 		
 	})
	function huadong(){
		var resize = document.getElementById("btn1");
        var left = document.getElementById("main-left");
        var right = document.getElementById("main-right");
        var box = document.getElementById("box");
        var childWindow = $("#templatelist")[0].contentWindow;
        resize.onmousedown = function(e){
            var startX = e.clientX;
            resize.left = resize.offsetLeft;
            document.onmousemove = function(e){
                var endX = e.clientX;

                var moveLen = resize.left + (endX - startX);
                mvl= endX - startX;
                var maxT = box.clientWidth - resize.offsetWidth;
                if(moveLen<150) moveLen = 150;
                if(moveLen>maxT-150) moveLen = maxT-150;

                resize.style.left = moveLen;
                left.style.width = moveLen + "px";
                right.style.width = (box.clientWidth - moveLen - 5-18) + "px";
                aaa=1;
                //alert(2222222222);
            }
            document.onmouseup = function(evt){
                document.onmousemove = null;
                document.onmouseup = null;
                resize.releaseCapture && resize.releaseCapture();
            }
            resize.setCapture && resize.setCapture();
            return false;
        };
	}
</script>
</html>